package miiteen.customsportal.Api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.module.param.service.SysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "获取系统参数")
@RequestMapping("/Api/SysParam")
public class GetSysParam {

    @Autowired
    private SysParamService sysParamService;

    @GetMapping("grayPage")
    @ApiOperation("一键灰度")
    public ResultMessage isGrayPage(){

        String result=sysParamService.getValByCode("grayPage");

        if("是".equals(result)){
            return ResultMessageTool.Success("一键灰度：1是，0否",1);
        }else if("否".equals(result)){
            return ResultMessageTool.Success("一键灰度：1是，0否",0);
        }
        return ResultMessageTool.Error("参数有误，请重新设置");
    }

    @GetMapping("findIp")
    @ApiOperation("获取ip地址")
    public ResultMessage findIp(){

        String result=sysParamService.getValByCode("getIp");

        if(result!=null&&result!=""){
            return ResultMessageTool.Success("获取当前的Ip地址",result);
        }
        return ResultMessageTool.Error("参数有误，请重新设置");
    }


}
